﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RoomNo.aspx.cs" Inherits="ZLDC.Estate.TM.RoomNo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <base target="_self" />
    <title>添加/修改房号信息</title>

    <script src="../js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

    <script src="../js/jquery/jquery.hiAlerts-min.js" type="text/javascript"></script>

    <script src="../js/LexunJS.js" type="text/javascript"></script>

    <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../js/jquery/style/jquery.hiAlerts.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        $(document).ready(function() {
            var type = LexunJS.GetQueryString("Type");  // 楼盘ID
            var typeid = LexunJS.GetQueryString("Typeid");
            document.getElementById("typeid").value = typeid;
            if (type == "Update") {
                document.getElementById("div3").style.display = "none";

            }
            document.getElementById("hType").value = "1";

        });
        function IsNan(obj) {
            if (isNaN(obj.value)) {
                alert("请输入数字");
                obj.value = "";
                obj.focus();
                return false;

            }
        }
        //查询是否重复输入房号
        function SelectRooms() {
            var bid = document.getElementById("txtBid").value;
            var floor = document.getElementById("txtFloor").value;
            var roomno = document.getElementById("txtRoomNo").value;
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerRoomNo.ashx',
                data: 'act=SelectCount&bid=' + bid + '&floor=' + floor + '&name=' + roomno,
                timeout: '10000',
                error: function() {
                    alert("系统繁忙，请稍后！");
                }, success: function(json) {
                    showDetailCallBack(json);
                }
            });
        }
        function showDetailCallBack(response) {
            var json = eval("(" + response + ")");
            var record = json.record;
            var isvalid;
            var id;
            if (record == null || record.length == 0) {
                 id = 0;
                 isvalid = "";
            } else {
                id = record[0].id;
                isvalid = record[0].isvalid;
            }
            if (id > 0) {
                if (isvalid == "1") {
                    document.getElementById("divc").style.display = "";
                    document.getElementById("divc").innerHTML = "<span><font color='red'>该房号已存在,状态(待审)！</font></span>";
                } else if (isvalid == "2") {
                    document.getElementById("divc").style.display = "";
                    document.getElementById("divc").innerHTML = "<span><font color='red'>该房号已存在,状态(无效)！</font></span>";
                }
                else {
                    document.getElementById("divc").style.display = "";
                }
                
                document.getElementById("txtRoomNo").value = "";
                return;
            } else {
                document.getElementById("divc").style.display = "none";
            }
        }
        //判断操作类型
        function changeType(typeid) {

            if (typeid == 1) {
                document.getElementById("div1").style.display = "";
                document.getElementById("div2").style.display = "none";
                document.getElementById("div4").style.display = "";
                document.getElementById("div5").style.display = "none";
                document.getElementById("divFloor").style.display = "";
                document.getElementById("divFloor1").style.display = "none";

                document.getElementById("hType").value = "1"; //单一新增

            } else {
                document.getElementById("div1").style.display = "none";
                document.getElementById("div2").style.display = "";
                document.getElementById("div4").style.display = "none";
                document.getElementById("div5").style.display = "";
                document.getElementById("divFloor").style.display = "none";
                document.getElementById("divFloor1").style.display = "";
                document.getElementById("hType").value = "2"; //批量新增
            }
        }

        function Check() {
            // 新增方式判断
            var bname = LexunJS.GetSelectText("buildName1");
            if (bname == "请选择") {
                alert("请选择栋阁！");
                return false;
            } else {
                if (bname.length = 0 || bname.replace(/(^\s*)|(\s*$)/g, "") == "") {
                    alert("请选择栋阁！");
                    return false;
                }
            }
            if (document.getElementById("rbt2").checked) {
                var reg = /^[A-Za-z]+$/;
                var name1 = document.getElementById("txtNum1").value;
                if (name1 == "") {
                    alert("批量新增房号名称中间不能为空！");
                    document.getElementById("txtNum1").focus();
                    return false;
                } else {
                if (!LexunJS.isValidPositiveInteger(name1) && !reg.test(name1)) {
                        alert("批量新增房号名称中间只能为正整数,以及字母！");
                        document.getElementById("txtNum1").focus();
                        return false;
                    }
                }

                var name2 = document.getElementById("txtNum2").value;
                if (name2 == "") {
                    alert("批量新增房号名称中间不能为空！");
                    document.getElementById("txtNum2").focus();
                    return false;
                } else {
                if (!LexunJS.isValidPositiveInteger(name2) && !reg.test(name2)) {
                        alert("批量新增房号名称中间只能为正整数,以及字母！");
                        document.getElementById("txtNum2").focus();
                        return false;
                    }
                }
            }

            if (document.getElementById("rbt1").checked) {
                var floorTotal = document.getElementById("txtFloor").value;
                if (floorTotal == "") {
                    alert("层数不能为空！");
                    document.getElementById("txtFloor").focus();
                    return false;
                } else {
                    if (!LexunJS.isValidPositiveInteger(floorTotal)) {
                        alert("层数只能为正整数！");
                        document.getElementById("txtFloor").focus();
                        return false;
                    }
                }
            } else {
                var floorTotal = document.getElementById("txtFloor1").value;
                if (floorTotal == "") {
                    alert("层数不能为空！");
                    document.getElementById("txtFloor1").focus();
                    return false;
                } else {
                    if (!LexunJS.isValidPositiveInteger(floorTotal)) {
                        alert("层数只能为正整数！");
                        document.getElementById("txtFloor1").focus();
                        return false;
                    }
                }

                var floorTotal2 = document.getElementById("txtFloor2").value;
                if (floorTotal2 == "") {
                    alert("层数不能为空！");
                    document.getElementById("txtFloor2").focus();
                    return false;
                } else {
                    if (!LexunJS.isValidPositiveInteger(floorTotal2)) {
                        alert("层数只能为正整数！");
                        document.getElementById("txtFloor2").focus();
                        return false;
                    }
                }
            }

            if (document.getElementById("rbt1").checked) {
                var roomno = document.getElementById("txtRoomNo").value;
                if (roomno == "") {
                    alert("房间号不能为空！");
                    document.getElementById("txtRoomNo").focus();
                    return false;
                }
            }


        }

        //加载栋阁
        function loadparentBuild() {
            var id = LexunJS.GetSelectValue("buildName1");

            if (id == "请选择") {
                document.getElementById("buildName2").options.length = 0;
                document.getElementById("buildName3").options.length = 0;
                $("#buildName2").html("");
                var obj = document.getElementById("buildName2");
                LexunJS.selectAddOption(obj, "请选择", 0);
                var obj1 = document.getElementById("buildName3");
                LexunJS.selectAddOption(obj1, "请选择", 0);
                return;
            }
            document.getElementById("build_name").value = LexunJS.GetSelectText("buildName1");
            document.getElementById("build_id").value = LexunJS.GetSelectValue("buildName1");
            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerIndex.ashx',
                data: 'act=SelectNamesByBId&id=' + id,
                timeout: '10000',
                error: function() {
                alert("系统繁忙，请稍后！");
                }, success: function(json) {
                    SelectNameByParent(json);
                }
            });
        }

        // 加载栋阁列表回调
        function SelectNameByParent(response) {
            var json = eval("(" + response + ")");
            var record = json.record;

            document.getElementById("buildName2").options.length = 0;
            document.getElementById("buildName3").options.length = 0;

            $("#buildName2").html("");
            var obj = document.getElementById("buildName2");
            LexunJS.selectAddOption(obj, "请选择", 0);
            if (record == null || record.length == 0) {
                document.getElementById("buildName2").style.display = "none";
                return;
            }
            document.getElementById("buildName2").style.display = "";
            var recordLength = record.length;
            for (var i = 0; i < recordLength; i++) {
                var sName = record[i].name;
                var sValue = record[i].id;
                LexunJS.selectAddOption(obj, sName, sValue);

            }
        }

        //加载栋阁
        function loadparentBuild3() {
            var id = LexunJS.GetSelectValue("buildName2");
            document.getElementById("build_name").value = LexunJS.GetSelectText("buildName2");
            document.getElementById("build_id").value = LexunJS.GetSelectValue("buildName2");
            var obj = document.getElementById("buildName3");
            if (id == 0) {
                document.getElementById("buildName3").options.length = 0;
                $("#buildName3").html("");
                LexunJS.selectAddOption(obj, "请选择", 0);
                return;
            }

            $.ajax({
                type: 'POST',
                url: '../Handler/HandlerIndex.ashx',
                data: 'act=SelectNamesByBId&id=' + id,
                timeout: '10000',
                error: function() {
                alert("系统繁忙，请稍后！");
                }, success: function(json) {
                    SelectNameByParent3(json);
                }
            });
        }

        // 加载城市列表回调
        function SelectNameByParent3(response) {
            var json = eval("(" + response + ")");
            var record = json.record;

            document.getElementById("buildName3").options.length = 0;

            $("#buildName3").html("");
            var obj = document.getElementById("buildName3");

            LexunJS.selectAddOption(obj, "请选择", 0);

            if (record == null || record.length == 0) {
                document.getElementById("buildName3").style.display = "none";
                return;
            }
            document.getElementById("buildName3").style.display = "";
            var recordLength = record.length;
            for (var i = 0; i < recordLength; i++) {
                var sName = record[i].name;
                var sValue = record[i].id;

                LexunJS.selectAddOption(obj, sName, sValue);
            }
        }
        function loadparentBuildName() {
            document.getElementById("build_name").value = LexunJS.GetSelectText("buildName3");
            document.getElementById("build_id").value = LexunJS.GetSelectValue("buildName3");

        }


        //验证房间号，不能输入中文
        function isChn(str) {

            if (str.value != "整层") {
                var reg = /^[A-Za-z0-9-+]+$/;
                if (!reg.test(str.value) && str.value != "") {
                    alert("请输入数字,字母,以及-,+，整层(-为多套连通房源用，+为双拼房源时用，请大家严格遵守)");
                    str.value = "";
                    str.focus();
                    return false;
                }
            }

        }
    </script>

</head>
<body>
    <form id="form1" runat="server" style="text-align: center">
    <div id="divc" style="display: none; position: absolute; top: 149px; left: 397px;">
        <span><font color='red'>该房号已存在！</font></span>
    </div>
    <div style="display: none">
        <asp:TextBox ID="txtBid" runat="server"></asp:TextBox>
    </div>
    <table id='tableList1' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>
        <tr>
            <td height='25' bgcolor='#F7F7F7' align="right">
                楼盘名称：
            </td>
            <td height='25' bgcolor='#FFFFFF' align="left">
                <asp:Label ID="lblEname" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td height='25' bgcolor='#F7F7F7' align="right">
                所属栋阁：
            </td>
            <td height='25' bgcolor='#FFFFFF' align="left">
                <%-- <asp:DropDownList ID="ddlBuild" runat="server"    CssClass="textstyle"
 Height="18px" Width="124px"   >--%>
                <%-- </asp:DropDownList>--%>
                <select id="buildName1" name="buildName1" onchange="loadparentBuild()" runat="server"
                    class="textstyle1" style="width:200px;">
                </select><select id="buildName2" name="buildName2" style="display: none; width: 75px"
                    onchange="loadparentBuild3()" class="textstyle1">
                </select><select id="buildName3" name="buildName3" style="display: none; width: 75px"
                    onchange="loadparentBuildName()" class="textstyle1">
                </select>
            </td>
        </tr>
        <tr>
            <td height='25' bgcolor='#F7F7F7' align="right">
                新增方式：
            </td>
            <td height='25' bgcolor='#FFFFFF' align="left">
                <input id="rbt1" type="radio" name="radioType" checked onclick="changeType(1)" />单一新增
                <div id="div3">
                    <input id="rbt2" type="radio" name="radioType" onclick="changeType(2)" />批量新增
                </div>
                <input id="hType" runat="server" type="hidden" />
            </td>
        </tr>
        <tr>
            <td height='25' bgcolor='#F7F7F7' align="right">
                层数：
            </td>
            <td height='25' bgcolor='#FFFFFF' align="left">
                <div id="divFloor" style="display: block">
                    <asp:TextBox ID="txtFloor" onblur="IsNan(this);" CssClass='textstyle' runat="server"></asp:TextBox>
                    层
                </div>
                <div id="divFloor1" style="display: none">
                    <asp:TextBox ID="txtFloor1" Width="60px" onblur="IsNan(this);" CssClass='textstyle'
                        runat="server"></asp:TextBox>到
                    <asp:TextBox ID="txtFloor2" Width="60px" onblur="IsNan(this);" CssClass='textstyle'
                        runat="server"></asp:TextBox>层<font color="red">顺序从小到大</font>
                </div>
            </td>
        </tr>
        <tr>
            <td height='25' bgcolor='#F7F7F7' align="right">
                用途：
            </td>
            <td height='25' bgcolor='#FFFFFF' align="left">
                <asp:DropDownList ID="ddlUsage" Height="18px" Width="124px" CssClass="textstyle"
                    runat="server">
                </asp:DropDownList>
            </td>
        </tr>
        <%-- <tr>
            <td  height='25' bgcolor='#FFFFFF' align="right">
                状态：</td>
            <td  height='25' bgcolor='#FFFFFF' align="left">
                <asp:DropDownList ID="ddlStatus"  Height="18px" Width="124px" CssClass="textstyle" runat="server">
                <asp:ListItem Value="1">出售</asp:ListItem>
                <asp:ListItem Value="2">出租</asp:ListItem>
                <asp:ListItem Value="3">即租即售</asp:ListItem>
                <asp:ListItem Value="4">未放盘</asp:ListItem>

                </asp:DropDownList>
            </td>
        </tr>--%>
        <tr>
            <td height='25' bgcolor='#F7F7F7' align="right">
                房号：
            </td>
            <td height='25' bgcolor='#FFFFFF' align="left">
                <div id="div1" style="display: block">
                    <asp:TextBox ID="txtRoomNo" onblur="isChn(this);SelectRooms();" ToolTip="请输入数字,字母,以及-,+，整层(-为多套连通房源用，+为双拼房源时用，请大家严格遵守)"
                        CssClass='textstyle' runat="server"></asp:TextBox><br/>例：填01或02或A或B或A+B或01+03或01-03
                </div>
                <div id="div2" style="display: none">
                前缀<input id="iNameFirst" name="iNameFirst" type="text" value="" class="textdocdown"
                        style="width: 10%" runat="server" />&nbsp;&nbsp;
                    中间<asp:TextBox ID="txtNum1" Width="30px" onblur="isChn(this);" runat="server" CssClass="textstyle"></asp:TextBox>~<asp:TextBox
                        CssClass="textstyle" Width="30px" ID="txtNum2" onblur="isChn(this);" runat="server"></asp:TextBox> 
                        
                 &nbsp;&nbsp;后缀<input id="iNameEnd" name="iNameEnd" type="text" value="" class="textdocdown" style="width: 10%"  runat="server"/>
                          <br/>前缀是指房号前面共同部份,如:A01, A02, A03,A04 .前缀填A,中间第一格填01；第二格填04
                           <br/>后缀是指房号后面共同部份,如:118, 128, 128,148 .中间第一格填12；第二格填14;后缀填8
                          <br/>没有前面后面共同的前后缀格不填 .如：户型01, 02, 03,04第一格填01；第二格填04.前后缀不填 <br/>户型从A,B,C,D的第一格填A;第二格填D．前后缀不填
               </div>
            </td>
        </tr>
        <tr>
            <td height='25' bgcolor='#F7F7F7' align="right">
                房号别名：
            </td>
            <td height='25' bgcolor='#FFFFFF' align="left">
                <div id="div4">
                    <asp:TextBox ID="txtOtherName" CssClass='textstyle' runat="server"></asp:TextBox>　(可不填)
                </div>
                <div id="div5" style="display: none">
                    <asp:TextBox ID="otherNum1" Width="30px" CssClass="textstyle" runat="server"></asp:TextBox>~<asp:TextBox
                        ID="otherNum2" Width="30px" CssClass="textstyle" runat="server"></asp:TextBox>　(可不填)
                </div>
            </td>
        </tr>
        <tr>
            <td height='25' bgcolor='#F7F7F7' align="right">
                备注：
            </td>
            <td height='25' bgcolor='#FFFFFF' align="left">
                <asp:TextBox ID="remark" CssClass='textstyle' runat="server" Height="79px" Width="147px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td height='25' bgcolor='#FFFFFF' colspan="2">
                <asp:Button ID="btnOK" CssClass="button_bak" Style="cursor: pointer;" runat="server"
                    Text="确定" OnClientClick="return Check();" OnClick="btnOK_Click" />
                &nbsp;&nbsp;
                <input id="btnExits" class="button_bak" type="button" value="关闭" onclick="window.close()"
                    style="cursor: pointer;" />
                <%--<asp:ImageButton ID="btnExits" runat="server" 
                   onclick="window.close();" ImageUrl="~/images/bot11.gif"/>--%>
            </td>
        </tr>
    </table>
    <font color="red">请输入数字,字母,以及-,+，整层(-为多套连通房源用，+为双拼房源时用，请大家严格遵守)</font>
    <div style="display: none">
        <asp:TextBox ID="build_id" runat="server"></asp:TextBox>
        <asp:TextBox ID="build_name" runat="server"></asp:TextBox>
        <asp:TextBox ID="typeid" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>
